 // ORDER MATTERS on all arrays. Here translate and put in alphabetical order
var classArrayLocalized = new Array();
i = 0;
classArrayLocalized[i] = "Shaman"; i++; // Shaman
classArrayLocalized[i] = "Hunter"; i++; // Hunter
classArrayLocalized[i] = "Warlock"; i++; // Warlock
classArrayLocalized[i] = "Druid"; i++; // Druid
classArrayLocalized[i] = "Warrior"; i++; // Warrior
classArrayLocalized[i] = "Mage"; i++; // Mage
classArrayLocalized[i] = "Paladin"; i++; // Paladin
classArrayLocalized[i] = "Priest"; i++; // Priest
classArrayLocalized[i] = "Rogue"; i++; // Rogue

var classArray = new Array(); // dont translate here (just order in the target alphabetical order), thats for the filenames
i = 0;
classArray[i] = "shaman"; i++;
classArray[i] = "hunter"; i++;
classArray[i] = "warlock"; i++;
classArray[i] = "druid"; i++;
classArray[i] = "warrior"; i++;
classArray[i] = "mage"; i++;
classArray[i] = "paladin"; i++;
classArray[i] = "priest"; i++;
classArray[i] = "rogue"; i++;

var posArrayT4 = {}; // used for T4 T5 set sepcifications
posArrayT4["druid"] = [1,2,3];
posArrayT4["hunter"] = [4];
posArrayT4["mage"] = [5];
posArrayT4["paladin"] = [6,7,8];
posArrayT4["priest"] = [9,10];
posArrayT4["rogue"] = [11];
posArrayT4["shaman"] = [12,13,14];
posArrayT4["warlock"] = [15];
posArrayT4["warrior"] = [16,17];        

var raceArrayLocalized = new Array(); // translate and put in Alphabetical order
i = 0;
raceArrayLocalized[i] = "Draenei"; i++;
raceArrayLocalized[i] = "Night Elf"; i++;
raceArrayLocalized[i] = "Blood Elf"; i++;
raceArrayLocalized[i] = "Gnome"; i++;
raceArrayLocalized[i] = "Human"; i++;
raceArrayLocalized[i] = "Undead"; i++;
raceArrayLocalized[i] = "Dwarf"; i++;
raceArrayLocalized[i] = "Orc"; i++;
raceArrayLocalized[i] = "Tauren"; i++;
raceArrayLocalized[i] = "Troll"; i++;

var raceArray = new Array(); // dont translate here (just order in the target alphabetical order), thats for the filenames
i = 0;
raceArray[i] = "Draenei"; i++;
raceArray[i] = "nightelf"; i++;
raceArray[i] = "bloodelf"; i++;
raceArray[i] = "gnome"; i++;
raceArray[i] = "human"; i++;
raceArray[i] = "undead"; i++;
raceArray[i] = "dwarf"; i++;
raceArray[i] = "orc"; i++;
raceArray[i] = "tauren"; i++;
raceArray[i] = "troll"; i++;

//Added*****************************
var whichFaction = new Array(); // set this array according to raceArray content
i = 0;
//Alliance = 0, Horde = 1
whichFaction[i] = 0; i++;
whichFaction[i] = 0; i++;
whichFaction[i] = 1; i++;
whichFaction[i] = 0; i++;
whichFaction[i] = 0; i++;
whichFaction[i] = 1; i++;
whichFaction[i] = 0; i++;
whichFaction[i] = 1; i++;
whichFaction[i] = 1; i++;
whichFaction[i] = 1;
//End Added**************************

var availableArray = new Array(); // this array needs to be in sync with classArrayLocalized
i = 0;
//draenei, nightelf, bloodelf, gnome, human, undead, dwarf, orc, tauren, troll
availableArray[i] = [1, 0, 0, 0, 0, 0, 0, 1, 1, 1]; i++; // Shaman; orc, tauren, troll (3)
availableArray[i] = [1, 1, 1, 0, 0, 0, 1, 1, 1, 1]; i++; // Hunter; dwarf, nightelf, orc, tauren, troll (5)
availableArray[i] = [0, 0, 1, 1, 1, 1, 0, 1, 0, 0]; i++; // Warlock; gnome, human, orc, undead (4)
availableArray[i] = [0, 1, 0, 0, 0, 0, 0, 0, 1, 0]; i++; // Druid; nightelf, tauren (2)
availableArray[i] = [1, 1, 0, 1, 1, 1, 1, 1, 1, 1]; i++; // Warrior; dwarf, gnome, human, nightelf, orc, tauren, troll, undead (8)
availableArray[i] = [1, 0, 1, 1, 1, 1, 0, 0, 0, 1]; i++; // Mage; gnome, human, troll, undead (4)
availableArray[i] = [1, 0, 1, 0, 1, 0, 1, 0, 0, 0]; i++; // Paladin; dwarf, human (2)
availableArray[i] = [1, 1, 1, 0, 1, 1, 1, 0, 0, 1]; i++; // Priest; dwarf, human, nightelf, troll, undead (5)
availableArray[i] = [0, 1, 1, 1, 1, 1, 1, 1, 0, 1]; // Rogue; dwarf, gnome, human, nightelf, orc, troll, undead (7)

var dblPoint = "&nbsp;:";
var selectArmortype = "Armor Set" + dblPoint;
var selectClass = "Class" + dblPoint;
var selectRace = "Race" + dblPoint;
var selectGender = "Gender" + dblPoint;
var selectSetSpec = "Set Specialization";

var male = "Male";
var female = "Female"

var mouseOverIcons = "&nbsp;Mouse over icons for item stats";

var armorSetsLocalized = new Array();
i = 0;
armorSetsLocalized[i] = "Dungeon Set 1"; i++;
armorSetsLocalized[i] = "Dungeon Set 2"; i++;
armorSetsLocalized[i] = "Tier 1 Raid Set"; i++;
armorSetsLocalized[i] = "Tier 2 Raid Set"; i++;
armorSetsLocalized[i] = "Tier 3 Raid Set"; whichIsTier3 = i; i++;
armorSetsLocalized[i] = "Tier 4 Raid Set"; i++;
armorSetsLocalized[i] = "Tier 5 Raid Set"; i++;
armorSetsLocalized[i] = "PvP - Superior"; whichIsPvPSuperior = i; i++;
armorSetsLocalized[i] = "PvP - Epic"; whichIsPvPEpic = i; i++;

function $(elem) { return document.getElementById(elem); }

function changeArmorSet(whichArmorSet, classNr) {
	theDungeonNumber = whichArmorSet;
	theDungeon = armorSetsValues[whichArmorSet];
    numberOfSlots = armorSetsArray[theDungeonNumber].slotsNumber;
    showItemID = 0;
    var theClassNumber2 = classNr;
	//alert('classNr'+classNr);
    switch (classNr) { // case 0 is the first position in classArrayLocalized, the second 0 points to the first set in dungeons1.js (position - 1) and so on..		
        case 0:  // Shamane 
            showItemID = 6 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[6];
            theClassNumber2 = 6;
        break;
        case 1: // Hunter 
            showItemID = 1 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[1];
            theClassNumber2 = 1;
        break;	
        case 2: // Warlock 
            showItemID = 7 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[7];
            theClassNumber2 = 7;
        break;			
		case 3: // Druide 			
            showItemID = 0 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[0];
            theClassNumber2 = 0;
        break;	
        case 4: // Warrior
            showItemID = 8 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[8];
            theClassNumber2 = 8;
        break;
        case 5: // Mage 
            showItemID = 2 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[2];
            theClassNumber2 = 2;
        break;
        case 6:  // Paladin 
            showItemID = 3 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[3];
            theClassNumber2 = 3;
        break;
        case 7:  // Priest 
            showItemID = 4 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[4];
            theClassNumber2 = 4;
        break;
        case 8:  // Rouge 
            showItemID = 5 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[5];
            theClassNumber2 = 5;
        break;
    }	
	//alert('classNr'+classNr+' theClassNumber2 '+theClassNumber2);
   if (whichArmorSet == 5 || whichArmorSet == 6) { // if t4 or t5
		fillSelectSetSpec(classNr); 
		setName = armorSetsArray[theDungeonNumber].setNamesArray[posArrayT4[classArray[classNr]][0]];
		showItemID = (posArrayT4[classArray[classNr]][document.forms["armorSets"].formSelectSetSpec.selectedIndex] * numberOfSlots) - numberOfSlots;
		document.getElementById('theImage').src = "armures/"+ theDungeon +"/"+ theClass +"/"+ theRace +"-"+ gender +".jpg";	
		document.getElementById('setName').innerHTML = setName;         
		switcherooo();		
		purgeSelectRace();
		fillSelectRace(classNr);
   } else {
	   	
       $("selectSetSpecDiv").style.display = "none";
       setName = armorSetsArray[theDungeonNumber].setNamesArray[theClassNumber2];
       showItemID = theClassNumber2 * numberOfSlots;
	   //alert('classNr'+classNr+'; theClassNumber2: '+theClassNumber2+'; theDungeon: '+theDungeon+'; setName: '+setName);
	   document.getElementById('theImage').src = "armures/"+ theDungeon +"/"+ theClass +"/"+ theRace +"-"+ gender +".jpg";	
		document.getElementById('setName').innerHTML = setName;         
		switcherooo();		
		purgeSelectRace();	
		fillSelectRace(classNr);
   }
    
}

var classChanged = 0;	

function changeSetSpec (setNumber, classNr) {
    theClass = classArray[classNr];    
    numberOfSlots = armorSetsArray[theDungeonNumber].slotsNumber;
        
    if (theDungeonNumber == 5 || theDungeonNumber == 6) { // if t4 or t5
        showItemID = (posArrayT4[classArray[classNr]][document.forms["armorSets"].formSelectSetSpec.selectedIndex] * numberOfSlots) - numberOfSlots;
    }
    
    setName = armorSetsArray[theDungeonNumber].setNamesArray[posArrayT4[classArray[classNr]][document.forms["armorSets"].formSelectSetSpec.selectedIndex]];
    document.getElementById('theImage').src = "armures/"+ theDungeon +"/"+ theClass +"/"+ theRace +"-"+ gender +".jpg";	
    document.getElementById('setName').innerHTML = setName;         
    switcherooo();		
	purgeSelectRace();
	fillSelectRace(theClassNumber);
}

function changeClass(whichClass) {
	theClassNumber = theClassNumber2 = whichClass;
	var whichClassName = classArray[whichClass];
	theClass = classArray[whichClass];

	numberOfSlots = armorSetsArray[theDungeonNumber].slotsNumber;

   
/* this is the order in dungeonsX.js (not changeable for easier future updates):
    1. "Druid"
    2. "Hunter"
    3. "Mage"
    4. "Paladin"
    5. "Priest"
    6. "Rouge"
    7. "Shamane"
    8. "Warlock"
    9. "Warrior"
*/

	showItemID = 0;
    switch (theClassNumber) { // case 0 is the first position in classArrayLocalized, the second 0 points to the first set in dungeons1.js (position - 1) and so on..
        case "0":  // Shamane 
            showItemID = 6 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[6];
            theClassNumber2 = 6;    
        break; 	
        case "1": // Hunter 
            showItemID = 1 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[1];
            theClassNumber2 = 1;
        break;		
        case "2": // Warlock 
            showItemID = 7 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[7];
            theClassNumber2 = 7;
        break;		
        case "3": // Druide 
            showItemID = 0 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[0];
            theClassNumber2 = 0;
        break;			
        case "4": // Warrior
            showItemID = 8 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[8];
            theClassNumber2 = 8;
        break;
        case "5": // Mage 
            showItemID = 2 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[2];
            theClassNumber2 = 2;
        break;
        case "6":  // Paladin 
            showItemID = 3 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[3];
            theClassNumber2 = 3;
        break;
        case "7":  // Priest 
            showItemID = 4 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[4];
            theClassNumber2 = 4;
        break;

        case "8":  // Rouge 
            showItemID = 5 * numberOfSlots;
            setName = armorSetsArray[theDungeonNumber].setNamesArray[5];
            theClassNumber2 = 5;
        break;
    }	
    theDungeonNumber = document.forms["armorSets"].formSelectArmorSet.options[document.forms["armorSets"].formSelectArmorSet.selectedIndex].value;
	whichClass = theClassNumber2;
    if (theDungeonNumber == 5 || theDungeonNumber == 6) { // if t4 or t5
       fillSelectSetSpec(theClassNumber); 
       setName = armorSetsArray[theDungeonNumber].setNamesArray[posArrayT4[classArray[theClassNumber]][0]];
       showItemID = (posArrayT4[classArray[theClassNumber]][document.forms["armorSets"].formSelectSetSpec.selectedIndex] * numberOfSlots) - numberOfSlots;
	   	if (availableArray[theClassNumber][theRaceNumber] == 0) {
			b = 0;
			while (availableArray[theClassNumber][b] == 0) {
				b++;
			}
			classChanged = 1;	
			changeRace(b);
		}
		document.getElementById('theImage').src = "armures/"+ theDungeon +"/"+ theClass +"/"+ theRace +"-"+ gender +".jpg";	
	    document.getElementById('setName').innerHTML = setName;
    
    	switcherooo();	
		purgeSelectRace();
		fillSelectRace(theClassNumber);
   } else {
       setName = armorSetsArray[theDungeonNumber].setNamesArray[theClassNumber2];
       showItemID = theClassNumber2 * numberOfSlots;
	   if (availableArray[theClassNumber][theRaceNumber] == 0) {
		b = 0;
		while (availableArray[theClassNumber][b] == 0) {
			b++;
		}
        classChanged = 1;	
     	changeRace(b);
		}
		document.getElementById('theImage').src = "armures/"+ theDungeon +"/"+ theClass +"/"+ theRace +"-"+ gender +".jpg";	
	    document.getElementById('setName').innerHTML = setName;
    
    	switcherooo();	

		purgeSelectRace();
		fillSelectRace(theClassNumber);
   }



}